package com.health.tablebean.webservice;

import android.content.Context;
import android.text.TextUtils;

import com.health.db.FDbManager;
import com.health.tablebean.ARCHIVE_BASEINFO;
import com.health.tablebean.CD_CHD_FOLLOWUP;
import com.health.tablebean.CD_DRUGCONDITION;
import com.health.tablebean.PharmacyList;
import com.health.viewscontrols.NovaApplication;

import net.tsz.afinal.annotation.sqlite.Id;
import net.tsz.afinal.annotation.sqlite.Table;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

/**
 * 冠心病
 * Created by ewenqiang on 2018/2/11 0011.
 */
@Table(name="CoronaryHeartDisease")
public class CoronaryHeartDisease {

    @Id(column="id")
    private String id;
    private String qdqxz;

    private String wzd;

    private String personalid;

    private String cardid;

    private String coronaryCardid;

    private String resDoctor;

    private String visitDate;

    private String visitWay;

    private String curSymptom;

    private String otherSymptom;

    private String stature;

    private String avoirdupois;

    private String targetAvoirdupois;

    private String physique;

    private String targetPhysique;

    private String hip;

    private String waostline;

    private String pressureH;

    private String pressureL;

    private String pulseRate;

    private String otherPositive;

    private String smoke;

    private String targetSmoke;

    private String drink;

    private String targetDrink;

    private String training;

    private String targetTraining;

    private String trainingMin;

    private String targetTrainingMin;

    private String salt;

    private String targetSalt;

    private String mentality;

    private String compiance;

    private String subCheck;

    private String dependence;

    private String sideEffects;

    private String effectsState;

    private String visitType;

    private String cmType;

    private String nextVisitDate;

    private String inputOrgancode;

    private String inputOrgan;

    private String inputIdcard;

    private String inputMan;

    private String updatetime;

    private String happentime;

    private String createtime;

    private String createorg;

    private String updateorg;

    private String creater;

    private String modified;

    private String res1;

    private String res2;

    private String res3;

    private String res4;

    private String res5;

    private String res6;

    private String res7;	//失访--具体失访原因（输入）

    private String res8;

    private String res9;

    private String res0;

    private String invalid;

    private String personalidOld;

    private String personalidNew;

    private String visitYear ;
    private String visitCount ;
    private HdPersonalRollOut rollout ;
    private List<HdPersonalPharmacy> pharmacyList;//dosage用量    drugName药名名称    reg2用药单位    usage用法
    private String xt;
    private String thxhdb;

    private String dietime;//死亡日期
    private String dieresult;//死亡原因
    private String sfresult;//失访原因
    private String qjbqk;//迁往地点基本情况
    private String qjjjl;//档案交接记录
    private String uploadtime;//上传时间
    private String IS_UPDATE;//是否上传
    private String height;//身高
    private String item0;//Pad专用辅助字段
    private String item1;
    private String item2;
    private String item3;
    private String item4;
    private String item5;

    public static List<CoronaryHeartDisease> convertData(Context context) {
        FDbManager fdb = FDbManager.getInstance(context);
        List<CoronaryHeartDisease> infos = fdb.findAllByWhere(CoronaryHeartDisease.class,
                "IS_UPDATE is not 'N' AND CREATEORG='" + NovaApplication.getJgbh() + "'");
        if (infos != null && !infos.isEmpty()) {
            for (CoronaryHeartDisease info : infos) {
                List<HdPersonalRollOut> listRollOut = fdb.findAllByWhere(HdPersonalRollOut.class,
                        "item0='" + info.getId()+"'");
                if(!TextUtils.isEmpty(info.getCardid())){
                    List<ARCHIVE_BASEINFO> ss=FDbManager.getInstance(context).findAllByWhere(ARCHIVE_BASEINFO.class,"IDCARD='"+info.getCardid()+"'");
                    if(ss.size()>0){
                        if(!ss.get(0).getPOPULATION_TYPE().contains("8")){
                            continue;
                        }
                    }
                    info.setCardid(info.getCardid().toUpperCase());
                }else if(!TextUtils.isEmpty(info.getPersonalid())){
                    List<ARCHIVE_BASEINFO> ss=FDbManager.getInstance(context).findAllByWhere(ARCHIVE_BASEINFO.class,"ARCHIVEID='"+info.getPersonalid()+"'");
                    if(ss.size()>0){
                        if(!ss.get(0).getPOPULATION_TYPE().contains("8")){
                            continue;
                        }
                        info.setCardid(ss.get(0).getIDCARD().toUpperCase());
                    }else{
                        info.setCardid("");
                    }
                }else{
                    info.setCardid("");
                }
                List<HdPersonalPharmacy> list = fdb.findAllByWhere(HdPersonalPharmacy.class,
                        "IDCARD='" + info.getCardid() + "' and TYPE='4'");
                if(list.size()>0){
                    for(HdPersonalPharmacy hdPersonalPharmacy:list){
                        hdPersonalPharmacy.setIDCARD(TextUtils.isEmpty(info.getCardid())? "":info.getCardid().toUpperCase());

                    }
                }
                info.setPharmacyList(list);

                if(listRollOut.size() >0 )

                    info.setRollout(listRollOut.get(0));
            }
        }
        return infos;
    }

    public String getHeight() {
        return height;
    }

    public void setHeight(String height) {
        this.height = height;
    }

    public String getItem0() {
        return item0;
    }

    public void setItem0(String item0) {
        this.item0 = item0;
    }

    public String getItem1() {
        return item1;
    }

    public void setItem1(String item1) {
        this.item1 = item1;
    }

    public String getItem2() {
        return item2;
    }

    public void setItem2(String item2) {
        this.item2 = item2;
    }

    public String getItem3() {
        return item3;
    }

    public void setItem3(String item3) {
        this.item3 = item3;
    }

    public String getItem4() {
        return item4;
    }

    public void setItem4(String item4) {
        this.item4 = item4;
    }

    public String getItem5() {
        return item5;
    }

    public void setItem5(String item5) {
        this.item5 = item5;
    }

    public HdPersonalRollOut getRollout() {
        return rollout;
    }

    public void setRollout(HdPersonalRollOut rollout) {
        this.rollout = rollout;
    }

    public List<HdPersonalPharmacy> getPharmacyList() {
        return pharmacyList;
    }

    public void setPharmacyList(List<HdPersonalPharmacy> pharmacyList) {
        this.pharmacyList = pharmacyList;
    }



    public String getUploadtime() {
        return uploadtime;
    }

    public void setUploadtime(String uploadtime) {
        this.uploadtime = uploadtime;
    }

    public String getIS_UPDATE() {
        return IS_UPDATE;
    }

    public void setIS_UPDATE(String IS_UPDATE) {
        this.IS_UPDATE = IS_UPDATE;
    }

    public String getQdqxz() {
        return qdqxz;
    }

    public void setQdqxz(String qdqxz) {
        this.qdqxz = qdqxz;
    }

    public String getWzd() {
        return wzd;
    }

    public void setWzd(String wzd) {
        this.wzd = wzd;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getPersonalid() {
        return personalid;
    }

    public void setPersonalid(String personalid) {
        this.personalid = personalid;
    }

    public String getCardid() {
        return cardid;
    }

    public void setCardid(String cardid) {
        this.cardid = cardid;
    }

    public String getCoronaryCardid() {
        return coronaryCardid;
    }

    public void setCoronaryCardid(String coronaryCardid) {
        this.coronaryCardid = coronaryCardid;
    }

    public String getResDoctor() {
        return resDoctor;
    }

    public void setResDoctor(String resDoctor) {
        this.resDoctor = resDoctor;
    }

    public String getVisitDate() {
        return visitDate;
    }

    public void setVisitDate(String visitDate) {
        this.visitDate = visitDate;
    }

    public String getVisitWay() {
        return visitWay;
    }

    public void setVisitWay(String visitWay) {
        this.visitWay = visitWay;
    }

    public String getCurSymptom() {
        return curSymptom;
    }

    public void setCurSymptom(String curSymptom) {
        this.curSymptom = curSymptom;
    }

    public String getOtherSymptom() {
        return otherSymptom;
    }

    public void setOtherSymptom(String otherSymptom) {
        this.otherSymptom = otherSymptom;
    }

    public String getStature() {
        return stature;
    }

    public void setStature(String stature) {
        this.stature = stature;
    }

    public String getAvoirdupois() {
        return avoirdupois;
    }

    public void setAvoirdupois(String avoirdupois) {
        this.avoirdupois = avoirdupois;
    }

    public String getTargetAvoirdupois() {
        return targetAvoirdupois;
    }

    public void setTargetAvoirdupois(String targetAvoirdupois) {
        this.targetAvoirdupois = targetAvoirdupois;
    }

    public String getPhysique() {
        return physique;
    }

    public void setPhysique(String physique) {
        this.physique = physique;
    }

    public String getTargetPhysique() {
        return targetPhysique;
    }

    public void setTargetPhysique(String targetPhysique) {
        this.targetPhysique = targetPhysique;
    }

    public String getHip() {
        return hip;
    }

    public void setHip(String hip) {
        this.hip = hip;
    }

    public String getWaostline() {
        return waostline;
    }

    public void setWaostline(String waostline) {
        this.waostline = waostline;
    }

    public String getPressureH() {
        return pressureH;
    }

    public void setPressureH(String pressureH) {
        this.pressureH = pressureH;
    }

    public String getPressureL() {
        return pressureL;
    }

    public void setPressureL(String pressureL) {
        this.pressureL = pressureL;
    }

    public String getPulseRate() {
        return pulseRate;
    }

    public void setPulseRate(String pulseRate) {
        this.pulseRate = pulseRate;
    }

    public String getOtherPositive() {
        return otherPositive;
    }

    public void setOtherPositive(String otherPositive) {
        this.otherPositive = otherPositive;
    }

    public String getSmoke() {
        return smoke;
    }

    public void setSmoke(String smoke) {
        this.smoke = smoke;
    }

    public String getTargetSmoke() {
        return targetSmoke;
    }

    public void setTargetSmoke(String targetSmoke) {
        this.targetSmoke = targetSmoke;
    }

    public String getDrink() {
        return drink;
    }

    public void setDrink(String drink) {
        this.drink = drink;
    }

    public String getTargetDrink() {
        return targetDrink;
    }

    public void setTargetDrink(String targetDrink) {
        this.targetDrink = targetDrink;
    }

    public String getTraining() {
        return training;
    }

    public void setTraining(String training) {
        this.training = training;
    }

    public String getTargetTraining() {
        return targetTraining;
    }

    public void setTargetTraining(String targetTraining) {
        this.targetTraining = targetTraining;
    }

    public String getTrainingMin() {
        return trainingMin;
    }

    public void setTrainingMin(String trainingMin) {
        this.trainingMin = trainingMin;
    }

    public String getTargetTrainingMin() {
        return targetTrainingMin;
    }

    public void setTargetTrainingMin(String targetTrainingMin) {
        this.targetTrainingMin = targetTrainingMin;
    }

    public String getSalt() {
        return salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }

    public String getTargetSalt() {
        return targetSalt;
    }

    public void setTargetSalt(String targetSalt) {
        this.targetSalt = targetSalt;
    }

    public String getMentality() {
        return mentality;
    }

    public void setMentality(String mentality) {
        this.mentality = mentality;
    }

    public String getCompiance() {
        return compiance;
    }

    public void setCompiance(String compiance) {
        this.compiance = compiance;
    }

    public String getSubCheck() {
        return subCheck;
    }

    public void setSubCheck(String subCheck) {
        this.subCheck = subCheck;
    }

    public String getDependence() {
        return dependence;
    }

    public void setDependence(String dependence) {
        this.dependence = dependence;
    }

    public String getSideEffects() {
        return sideEffects;
    }

    public void setSideEffects(String sideEffects) {
        this.sideEffects = sideEffects;
    }

    public String getEffectsState() {
        return effectsState;
    }

    public void setEffectsState(String effectsState) {
        this.effectsState = effectsState;
    }

    public String getVisitType() {
        return visitType;
    }

    public void setVisitType(String visitType) {
        this.visitType = visitType;
    }

    public String getCmType() {
        return cmType;
    }

    public void setCmType(String cmType) {
        this.cmType = cmType;
    }

    public String getNextVisitDate() {
        return nextVisitDate;
    }

    public void setNextVisitDate(String nextVisitDate) {
        this.nextVisitDate = nextVisitDate;
    }

    public String getInputOrgancode() {
        return inputOrgancode;
    }

    public void setInputOrgancode(String inputOrgancode) {
        this.inputOrgancode = inputOrgancode;
    }

    public String getInputOrgan() {
        return inputOrgan;
    }

    public void setInputOrgan(String inputOrgan) {
        this.inputOrgan = inputOrgan;
    }

    public String getInputIdcard() {
        return inputIdcard;
    }

    public void setInputIdcard(String inputIdcard) {
        this.inputIdcard = inputIdcard;
    }

    public String getInputMan() {
        return inputMan;
    }

    public void setInputMan(String inputMan) {
        this.inputMan = inputMan;
    }

    public String getUpdatetime() {
        return updatetime;
    }

    public void setUpdatetime(String updatetime) {
        this.updatetime = updatetime;
    }

    public String getHappentime() {
        return happentime;
    }

    public void setHappentime(String happentime) {
        this.happentime = happentime;
    }

    public String getCreatetime() {
        return createtime;
    }

    public void setCreatetime(String createtime) {
        this.createtime = createtime;
    }

    public String getCreateorg() {
        return createorg;
    }

    public void setCreateorg(String createorg) {
        this.createorg = createorg;
    }

    public String getUpdateorg() {
        return updateorg;
    }

    public void setUpdateorg(String updateorg) {
        this.updateorg = updateorg;
    }

    public String getCreater() {
        return creater;
    }

    public void setCreater(String creater) {
        this.creater = creater;
    }

    public String getModified() {
        return modified;
    }

    public void setModified(String modified) {
        this.modified = modified;
    }

    public String getRes1() {
        return res1;
    }

    public void setRes1(String res1) {
        this.res1 = res1;
    }

    public String getRes2() {
        return res2;
    }

    public void setRes2(String res2) {
        this.res2 = res2;
    }

    public String getRes3() {
        return res3;
    }

    public void setRes3(String res3) {
        this.res3 = res3;
    }

    public String getRes4() {
        return res4;
    }

    public void setRes4(String res4) {
        this.res4 = res4;
    }

    public String getRes5() {
        return res5;
    }

    public void setRes5(String res5) {
        this.res5 = res5;
    }

    public String getRes6() {
        return res6;
    }

    public void setRes6(String res6) {
        this.res6 = res6;
    }

    public String getRes7() {
        return res7;
    }

    public void setRes7(String res7) {
        this.res7 = res7;
    }

    public String getRes8() {
        return res8;
    }

    public void setRes8(String res8) {
        this.res8 = res8;
    }

    public String getRes9() {
        return res9;
    }

    public void setRes9(String res9) {
        this.res9 = res9;
    }

    public String getRes0() {
        return res0;
    }

    public void setRes0(String res0) {
        this.res0 = res0;
    }

    public String getInvalid() {
        return invalid;
    }

    public void setInvalid(String invalid) {
        this.invalid = invalid;
    }

    public String getPersonalidOld() {
        return personalidOld;
    }

    public void setPersonalidOld(String personalidOld) {
        this.personalidOld = personalidOld;
    }

    public String getPersonalidNew() {
        return personalidNew;
    }

    public void setPersonalidNew(String personalidNew) {
        this.personalidNew = personalidNew;
    }

    public String getVisitYear() {
        return visitYear;
    }

    public void setVisitYear(String visitYear) {
        this.visitYear = visitYear;
    }

    public String getVisitCount() {
        return visitCount;
    }

    public void setVisitCount(String visitCount) {
        this.visitCount = visitCount;
    }


    public String getXt() {
        return xt;
    }

    public void setXt(String xt) {
        this.xt = xt;
    }

    public String getThxhdb() {
        return thxhdb;
    }

    public void setThxhdb(String thxhdb) {
        this.thxhdb = thxhdb;
    }

    public String getDietime() {
        return dietime;
    }

    public void setDietime(String dietime) {
        this.dietime = dietime;
    }

    public String getDieresult() {
        return dieresult;
    }

    public void setDieresult(String dieresult) {
        this.dieresult = dieresult;
    }

    public String getSfresult() {
        return sfresult;
    }

    public void setSfresult(String sfresult) {
        this.sfresult = sfresult;
    }

    public String getQjbqk() {
        return qjbqk;
    }

    public void setQjbqk(String qjbqk) {
        this.qjbqk = qjbqk;
    }

    public String getQjjjl() {
        return qjjjl;
    }

    public void setQjjjl(String qjjjl) {
        this.qjjjl = qjjjl;
    }
}
